package com.glory.cqaospda.viewmodel

import com.glory.cqaospda.base.Constant
import com.glory.cqaospda.model.TaskRepository
import com.glory.mvvmnet.base.BaseViewModel
import com.glory.mvvmnet.entity.CallObserveBean
import com.glory.mvvmnet.entity.ToastMessageBean
import com.google.gson.JsonObject

class RepairModel:BaseViewModel() {

    private val repository by lazy { TaskRepository() }

    fun defaultRepair(map : JsonObject){

        launchOnlyResult({
            repository.defaultRepair(map,"EMS_Repair")
            defUI.callObserve.value = CallObserveBean(2)
        })
    }

    fun defaultGetBaseConfig(){

        val map = JsonObject()
        map.addProperty("GroupID", "maintain_item")

        launchOnlyResult({
            val baseConfigBean =
                repository.defaultGetBaseConfig(map,"EMS_GetBaseConfig")
            defUI.callObserve.value = CallObserveBean(1,baseConfigBean)
        })
    }

    fun defaultEqpInfo(eqpID: String) {
        val map = JsonObject()
        map.addProperty("EqpId", eqpID)
        launchOnlyResult({
            val defaultEqpInfo =
                repository.defaultEqpInfo(map,"EMS_GetEqpInfo")
            Constant.eqpid = eqpID
            defUI.callObserve.value = CallObserveBean(3,defaultEqpInfo)
        })
    }

}